<style scoped lang="less">
    .index{
        width: 100%;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        text-align: center;

        .ivu-row-flex{
            height: 100%;
        }
// .amine-mat{
//     font-size: 20px;
//     font-weight: bold;
//     width:300px;
//     height:100px;
//     line-height: 100px;
//     text-align:center;
//     // background:red;
//     position:relative;
//     animation:myfirst 8s infinite;
//     -webkit-animation:myfirst 8s infinite; 
//         }
// @keyframes myfirst
// {
//     0%   {color:red; left:20%; top:0px;}
//     25%  {color:yellow; left:60%; top:0px;}
//     50%  {color:blue; left:60%; top:200px;}
//     75%  {color:green; left:20%; top:200px;}
//     100% {color:red; left:20%; top:0px;}
// }

// @-webkit-keyframes myfirst /* Safari and Chrome */
// {
//     0%   {color:red; left:0px; top:0px;}
//     25%  {color:yellow; left:200px; top:0px;}
//     50%  {color:blue; left:200px; top:200px;}
//     75%  {color:green; left:0px; top:200px;}
//     100% {color:red; left:0px; top:0px;}
// }
    }
</style>
<template>
    <div class="index">
         <!-- <div class="amine-mat">混沌大学北京分社欢迎你！</div> -->
        <Row type="flex" justify="center" align="middle">
            <Col span="24">
            <Form ref="formInline" :model="formInline" :rules="ruleInline" inline >
            <Col span="24">
        <FormItem prop="user" style="width: 250px">
            <Input type="text" v-model.trim="formInline.user" placeholder="姓名">
                <Icon type="ios-person-outline" slot="prepend"></Icon>
            </Input>
        </FormItem>
         </Col>
              <Col span="24">
        <FormItem prop="password" style="width: 250px">
            <Input type="password" v-model.trim="formInline.password" placeholder="密码"@keyup.enter.native="handleSubmit('formInline')" >
                <Icon type="ios-lock-outline" slot="prepend"></Icon>
            </Input>
        </FormItem>
          </Col>
           <Col span="24">
        <FormItem>
            <Button type="primary" @click="handleSubmit('formInline')">登录</Button>
        </FormItem>
         </Col>
    </Form>
            </Col>
        </Row>
    </div>
</template>
<script>
   export default {
        data () {
            return {
                formInline: {
                    user: '',
                    password: ''
                },
                ruleInline: {
                    user: [
                        { required: true, message: '请输入姓名', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' },
                        { type: 'string', min: 6, message: '至少6位数', trigger: 'blur' }
                    ]
                }
            }
        },
        methods: {
            handleSubmit(name) {
                var that=this;
                var  hasity="";
            var  hasity= this.$route.query.history;
                this.$refs[name].validate((valid) => {
                    if (valid) {
                   this.axios({
                      method: 'get',
                      url: this.Util.URL()+'/apiClientBackend/admin/token?username='+this.formInline.user+'&password='+this.formInline.password
                    }).then(function (res) {
                        console.log(5555)
                            console.log(res.data)
                            if (res.data.status==3) 
                                {
                                    that.$Message.error('用户不存在');
                                }else if(res.data.status==1){
                       that.$Message.success('成功!');
                       if (hasity==1) 
                           {
                              that.$router.go(-1); 
                           }else{
                             that.$router.push({path:'/Catalog'})
                           }
                           
                       
                                    console.log(res.data.data.token)
                                    sessionStorage.setItem("Token",res.data.data.token)
                                }else if(res.data.status==2){
                        that.$Message.error('密码错误');           
                                }
                                
                    }).catch(function (error) {
                      console.log(error)
                    })
                        



                        // this.$Message.success('成功!');
                        // this.$router.push({path:'/Catalog'})
                    } else {
                        this.$Message.error('登录失败!');
                    }
                })
            }
        }
    }
</script>
